package com.sailorj.medical.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.sailorj.medical.domain.policy.Policy;
import com.sailorj.medical.exception.DbException;
import com.sailorj.medical.util.MyTime;

public class PolicyDao extends GenericDao<Policy> {

	@Override
	protected Policy handle(ResultSet rs) throws SQLException {
		String id = rs.getString("id");
		String year = rs.getString("year");
		String rate = rs.getString("rate");
		String max_line = rs.getString("max_line");

		Policy entity = new Policy(id, year, rate, max_line);
		return entity;
	}

	/**
	 * 按年份查询标准基金
	 */
	public List<Policy> findByYear() throws DbException {
		String year = MyTime.getStringNowYear();
		try {
			String sql = "select * from t_policy where 1=1 and year=" + year + "";

			Object[] params = {};

			return super.queryOjects(sql, params);
		} catch (SQLException e) {
			throw new DbException("按级别查找行政区域失败!", e);
		}
	}

}
